package com.heima.article.feign;

import com.heima.article.service.ApArticleConfigService;
import com.heima.article.service.ApArticleService;
import com.heima.feign.article.IArticleClient;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.comment.dtos.CommentNewsQueryDto;
import com.heima.model.article.pojos.ApArticleConfig;
import com.heima.model.comment.dtos.CommentConfigDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.StatisticsDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

import java.util.List;

/**
 * @author jack
 * @data 2024 15:19
 */
@Slf4j
@RestController
public class ArticleClient implements IArticleClient {
    @Autowired
    private ApArticleService apArticleService;
    @Autowired
    private ApArticleConfigService apArticleConfigService;

    /**
     * 功能描述：分页条件查询文章评论
     *
     * @param dto
     * @return {@link ResponseResult }
     * @author sungang
     * @date 2024/01/27  14:38
     */

    @Override
    @PostMapping("api/v1/article/findNewsComments")
    public PageResponseResult findnewsQueryComents(@RequestBody CommentNewsQueryDto dto) {
        return apArticleService.findnewsQueryComents(dto);
    }

    /**
     * 新增或修改app文章信息
     *
     * @param articleDto
     * @return
     */
    @Override
    @PostMapping("/api/v1/article/saveOrUpdate")
    public ResponseResult saveArticle(@RequestBody ArticleDto articleDto) {
        return apArticleService.saveOrUpdateArticle(articleDto);
    }

    /**
     * 功能描述：更新文章评论状态
     *
     * @param
     * @return {@link ResponseResult }
     * @author sungang
     * @date 2024/01/27  17:01
     */

    @PostMapping("/api/v1/article/updateCommentStatus")
    @Override
    public ResponseResult updateCommentStatus(@RequestBody CommentConfigDto dto) {
        return apArticleConfigService.updateCommentStatus(dto);
    }


    @Override
    @PostMapping("api/v1/article/findById")
    public ApArticleConfig findById(@RequestParam("articleId") Long articleId) {
        return apArticleConfigService.findById(articleId);
    }

    @Override
    @PostMapping("/api/v1/article/newPage")
    public PageResponseResult newPage(@RequestBody StatisticsDto dto) {
        System.out.println("文章服务的newPage");
        return apArticleService.newPage(dto);
    }

    @Override
    public ResponseResult countAllDate(@RequestParam("wmUserId") Integer wmUserId,
                                       @RequestParam("beginDate") Date beginDate,
                                       @RequestParam("endDate") Date endDate) {
        System.out.println("countAllDate方法");
        return apArticleService.countAllDate(wmUserId,beginDate,endDate);
    }
}
